home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
pctj8508.arc
/
PENTATH.PLI
< prev
next >
Wrap
Text File
|
1986-09-14
|
4KB
|
160 lines
/* The Pentathlon Program
Translated to PL/1 from the PASCAL version by Mark
Townsend & Robert Barnes. The PASCAL versions were
translated from the C version of these routines by
Michael Brian Bentley. Originally written by William
J. Hunt for PC-TECH Journal readers everywhere.
*/
pentathalon: proc options (main);
dcl (i,niter,ibench) bin fixed(15);
niter=100;
/* main program */
do ibench=1 to 4;
put skip edit('100 iterations ', ibench)(skip,a, f(3));
put list('starting ');
call puttime;
do i = 1 to niter;
if ibench=1 then call bench1;
if ibench=2 then call bench2;
if ibench=3 then call bench3;
if ibench=4 then call bench4;
end;
put skip list('finished ');
call puttime;
end;
put skip list ('create file for benchmark 5');
call makefile;
put skip list('starting I/O benchmark');
call puttime;
call bench5;
put skip list('finished ');
call puttime;
bench1:procedure; /* floating point arithmetic benchmark */
dcl (i,j) bin fixed;
dcl (x,y) (0:99) float,
z float;
do i = 0 to 99;
x(i) = i + 1;
y(i) = 3 + i;
end;
z = 0;
do j = 0 to 9;
do i = 0 to 99;
z = z + x(i) * y(i);
end;
end;
end bench1;
bench2:procedure; /* function calling benchmark */
dcl i bin fixed(15);
do i = 0 to 19999 ;
call dummy((i)); /* calls a dummy procedure */
/* i doesn't change */
end;
dummy:procedure(pi);
dcl pi bin fixed(15);
pi = pi + 1;
end;
end bench2;
bench3:procedure; /* string copy benchmark */
dcl i bin fixed;
dcl s(500) char(1);
dcl s2(500) char(1);
do i=1 to 499;
s(i)='a';
end;
s(500)=ascii(0);
do i = 1 to 100;
s2=s;
end;
end bench3;
bench4: procedure ; /* character count benchmark */
dcl i bin fixed(15);
dcl s(500) char(1);
dcl cnt(0:255) bin fixed;
/* bench4 - initialize string array for counting */
do i = 1 to 500;
s(i) = ascii(i);
end;
do i = 1 to 100;
call count_char(s,cnt);
end;
count_char:proc(strng,counts);
dcl strng(500) char(1);
dcl counts(0:255) bin fixed;
dcl i bin fixed(15);
dcl c char(1);
dcl idx bin fixed;
do i=1 to 500;
idx = rank(strng(i));
counts( idx ) = counts( idx ) + 1;
end;
end count_char;
end bench4;
bench5:proc; /* file copy with getc/putc */
dcl n bin fixed(15);
dcl (infile,outfile) file;
dcl data char(1) var;
open file(infile) stream input title('test.in' );
open file(outfile) stream output print title('test.out' );
n = 0;
on endfile(infile) goto exit;
do while('1'b);
n = n + 1;
get file(infile) edit(data)(a(1));
put file(outfile) edit(data)(a(1));
end;
exit:put skip;
put edit(n,' characters')(skip,f(7),a);
close file(infile);
close file(outfile);
end bench5;
makefile:proc; /* create a test file */
dcl victim file;
dcl n bin fixed(15);
/* makefile */
open file(victim) stream output print title('test.in');
do n = 0 to 29999;
put file(victim) edit('a')(a(1));
end;
close file(victim);
end;
puttime: procedure;
declare gettime entry (pointer,pointer,pointer,pointer);
declare (hour,min,sec,fraction) fixed(7);
call gettime(addr(hour),addr(min),addr(sec),addr(fraction));
put skip list('The time is now ');
put edit(hour,':',min,':',sec,'.',fraction)
(f(2),a,f(2),a,f(2),a,f(2));
end puttime;
end pentathalon;